package com.cory.module.job.controller;

import com.cory.boot.base.BaseController;
import com.cory.boot.utils.SysUtils;
import com.cory.module.job.core.JobFactory;
import com.cory.module.job.domain.entity.JobAsync;
import com.cory.module.job.service.JobAsyncService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author xiongcong
 * @date 2023-05-09
 */
@Controller
@RequestMapping("admin/job/async")
public class JobAsyncController extends BaseController {
    @Autowired
    private JobAsyncService jobAsyncService;

    @RequestMapping("list")
    public String list(JobAsync param, Model model) {
        param.setTenantId(SysUtils.getLoginTenantId());
        param.setSystem(SysUtils.getSystem());

        super.startPage();
        List<JobAsync> list = jobAsyncService.list(param);

        model.addAttribute("page", new PageInfo<>(list));
        model.addAttribute("param", param);
        model.addAttribute("annotationMap", JobFactory.getAsyncJobAnnotationMap());
        return "admin/job/async/list";
    }
}
